package com.hncc.bms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hncc.bms.domain.BmsSettlementCat;
import com.hncc.bms.service.IBmsSettlementCatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 结算类别Controller
 * 
 * @author HYJ
 * @date 2020-08-23
 */
@RestController
@RequestMapping("/bms/settlement_cat")
public class BmsSettlementCatController extends BaseController
{
    @Autowired
    private IBmsSettlementCatService bmsSettlementCatService;

    /**
     * 查询结算类别列表
     */
    @PreAuthorize("@ss.hasPermi('bms:settlement_cat:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsSettlementCat bmsSettlementCat)
    {
        startPage();
        List<BmsSettlementCat> list = bmsSettlementCatService.selectBmsSettlementCatList(bmsSettlementCat);
        return getDataTable(list);
    }

    /**
     * 导出结算类别列表
     */
    @PreAuthorize("@ss.hasPermi('bms:settlement_cat:export')")
    @Log(title = "结算类别", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmsSettlementCat bmsSettlementCat)
    {
        List<BmsSettlementCat> list = bmsSettlementCatService.selectBmsSettlementCatList(bmsSettlementCat);
        ExcelUtil<BmsSettlementCat> util = new ExcelUtil<BmsSettlementCat>(BmsSettlementCat.class);
        return util.exportExcel(list, "settlement_cat");
    }

    /**
     * 获取结算类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('bms:settlement_cat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmsSettlementCatService.selectBmsSettlementCatById(id));
    }

    /**
     * 新增结算类别
     */
    @PreAuthorize("@ss.hasPermi('bms:settlement_cat:add')")
    @Log(title = "结算类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsSettlementCat bmsSettlementCat)
    {
        return toAjax(bmsSettlementCatService.insertBmsSettlementCat(bmsSettlementCat));
    }

    /**
     * 修改结算类别
     */
    @PreAuthorize("@ss.hasPermi('bms:settlement_cat:edit')")
    @Log(title = "结算类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsSettlementCat bmsSettlementCat)
    {
        return toAjax(bmsSettlementCatService.updateBmsSettlementCat(bmsSettlementCat));
    }

    /**
     * 删除结算类别
     */
    @PreAuthorize("@ss.hasPermi('bms:settlement_cat:remove')")
    @Log(title = "结算类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmsSettlementCatService.deleteBmsSettlementCatByIds(ids));
    }
}
